{% include 'header' %}

import Swinject

final class {{ prefix }}{{ module_info.name }}ModuleAssembly: Assembly {
    func assemble(container: Container) {
        container.register({{ prefix }}{{ module_info.name }}Interactor.self) { (_, presenter: {{ prefix }}{{ module_info.name }}Presenter) in 
            let interactor = {{ prefix }}{{ module_info.name }}Interactor()
            interactor.output = presenter
            return interactor
        }

        container.register({{ prefix }}{{ module_info.name }}Router.self) { (_, viewController: {{ prefix }}{{ module_info.name }}ViewController) in
            let router = {{ prefix }}{{ module_info.name }}Router()
            router.transitionHandler = viewController
            return router
        }

        container.register({{ prefix }}{{ module_info.name }}ModuleInput.self) { (resolver, viewController: {{ prefix }}{{ module_info.name }}ViewController) in 
            let presenter = {{ prefix }}{{ module_info.name }}Presenter()

            presenter.view = viewController
            presenter.interactor = resolver.resolve({{ prefix }}{{ module_info.name }}Interactor.self, argument: presenter)
            presenter.router = resolver.resolve({{ prefix }}{{ module_info.name }}Router.self, argument: viewController)

            return presenter
        }

        container.register({{ prefix }}{{ module_info.name }}ViewController.self) { (resolver) in
            let viewController = ViewControllerFactory.instantiate(.{{ prefix }}{{ module_info.name }}) as {{ prefix }}{{ module_info.name }}ViewController
            viewController.output = resolver.resolve({{ prefix }}{{ module_info.name }}ModuleInput.self, argument: viewController) as? {{ prefix }}{{ module_info.name }}Presenter
            return viewController
        }
    }
}